package org.beetl.sql.core;

import org.beetl.sql.clazz.LegacyNameConversion;
import org.beetl.sql.clazz.kit.StringKit;

public class LegacyUnderlinedNameConversion extends LegacyNameConversion{

	@Override
	public String getTableName(Class<?> clazz) {
		String name = getAnnotationTableName(clazz);
		if(name!=null){
			return name;
		}
		return StringKit.enCodeUnderlined(clazz.getSimpleName());
	}

	@Override
	public String getColName(Class<?> c, String attrName) {
		String col = super.getAnnotationColName(c,attrName);
		if(col!=null){
			return col;
		}
		return StringKit.enCodeUnderlined(attrName);
	}

	@Override
	public String getPropertyName(Class<?> c, String colName) {
		String attrName = super.getAnnotationAttrName(c,colName);
		if(attrName!=null){
			return attrName;
		}
		return StringKit.deCodeUnderlined(colName.toLowerCase());
	}

}
